﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BackupMirthToTFS
{
    public static class MirthBackupDAL
    {
        public static IQueryable<MirthBackup> ListActiveMirthTargets()
        {
            var db = new MirthBackupDataContext(Config.BackupMirthToTFSConnString);
            return db.MirthBackups.Where(x => x.IsActive == true);
        }

        public static void MarkBackupAsSuccessful(short id)
        {
            using (var db = new MirthBackupDataContext(Config.BackupMirthToTFSConnString))
            {
                var backup = db.MirthBackups.SingleOrDefault(x => x.ID == id);
                backup.LastCompletedOn = DateTime.Now;
                db.SubmitChanges();
            }
        }

    }
}
